// 无重复的最长子串
// 双指针
s = "abcabcbb"

var lengthOfLongestSubstring = function(s) {
    let left = 0, right = 0, maxlen = 0
    let window = {}
    while(right < s.length) {
        let cur = s[right]
        right++
        if(window[cur]) window[cur]++ 
        else window[cur] = 1

        while (window[cur] > 1) {
            let pre = s[left]
            left++
            window[pre]--
        }
        if(right - left > maxlen) {
            maxlen = right - left
        }
    }
    return maxlen
}